package org.patterns.behavior.visitor;


/**
 * 财务部类：具体访问者类
 */
public class FinanceDepartment extends Department {
    /**
     * 实现财务部对全职员工的访问
     * 访问全职员工对象，根据其工作时间计算并打印其实际工资
     * 如果工作时间超过40小时，超过部分每小时补贴100元
     * 如果工作时间不足40小时，不足部分每小时扣80元，但最低工资为0元
     *
     * @param employee FulltimeEmployee类型的员工对象，包含员工的基本信息
     */
    public void visit(FulltimeEmployee employee) {
        int workTime = employee.getWorkTime();
        double weekWage = employee.getWeeklyWage();
        if (workTime > 40) {
            weekWage = weekWage + (workTime - 40) * 100;
        } else if (workTime < 40) {
            weekWage = weekWage - (40 - workTime) * 80;
            if (weekWage < 0) {
                weekWage = 0;
            }
        }
        System.out.println("正式员工" + employee.getName() + "实际工资为：" + weekWage + "元。");
    }

    /**
     * 实现财务部对兼职员工的访问
     * 访问兼职员工对象，根据其工作时间和小时工资计算并打印其实际工资
     * 兼职员工的工资计算方式为工作时间乘以小时工资
     *
     * @param employee ParttimeEmployee类型的员工对象，包含员工的基本信息
     */
    public void visit(ParttimeEmployee employee) {
        int workTime = employee.getWorkTime();
        double hourWage = employee.getHourWage();
        System.out.println("临时工" + employee.getName() + "实际工资为：" + workTime * hourWage + "元。");
    }

}
